﻿using L7_Modularity;
using L7_Modularity.Views;
using Prism.Ioc;
using Prism.Modularity;
using System;
using System.Reflection;
using System.Windows;

namespace L7_Modularity;

/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App
{
    protected override Window CreateShell()
    {
        return Container.Resolve<MainWindow>();
    }

    protected override void RegisterTypes(IContainerRegistry containerRegistry)
    {

    }

    protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
    {
        // 使用代码加载模块
        // moduleCatalog.AddModule<ModuleA.ModuleAModule>("ModuleAModule", InitializationMode.WhenAvailable); // 直接加载
        moduleCatalog.AddModule<ModuleA.ModuleAModule>("ModuleAModule", InitializationMode.OnDemand); // 按需加载
    }

    protected override IModuleCatalog CreateModuleCatalog()
    {
        //return new ConfigurationModuleCatalog(); // 使用 App.config 配置文件
        return new DirectoryModuleCatalog() { ModulePath = @".\Modules" }; // 使用目录加载模块
    }
}